/** 节流 */
const delay = ((): any => {
	let timer: any = 0;
	return (_callBack: any, ms: number) => {
		clearTimeout(timer);
		timer = setTimeout(_callBack, ms);
	};
})();

const debounce = function(fn: any, delay: number) {
    let timer = null
    const that = this
    return function() {
        const param = arguments
        if (timer) {
            window.clearTimeout(timer)
        }
        timer = window.setTimeout(function() {
            fn.apply(that, param)
        }, delay)
    }
}

export { delay, debounce };
